package hot100;

public class maxArea {
    public int maxArea(int[] height) {
        //right-left * min(hr,hl)
        int left = 0;
        int right = height.length-1;
        //最大水容量
        int sum = 0;
        while(left < right) {
            int min = Math.min(height[left],height[right]);
            //更新sum
            sum = Math.max(sum,(right-left)*min);
            //舍弃掉较小的容器壁
            if(height[left] < height[right]) {
                left++;
            }else {
                right--;
            }
        }
        return sum;
    }
}
